﻿using System;
using System.Collections.Generic;
using Internal.Runtime.Models;

namespace Runtime.Models {

    public interface IDFR_FeatureModel : IDFR_Model
    {

        bool Share { get; }

        bool SideBar { get; }

        bool Desktop { get; }

        bool GameClub { get; }

        bool AddMiniProgram { get; }
        
        bool Subscribe { get; }
    }

    [Implement(typeof(IDFR_FeatureModel))]
    internal sealed class DFR_FeatureModel : DFR_Model, IDFR_FeatureModel, IDFR_FeatureModelInternal
    {

        protected override void Dispose() {
            foreach (var item in m_ShareItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }
            foreach (var item in m_SideBarItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }
            foreach (var item in m_DesktopItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }
            foreach (var item in m_GameClubItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }
            foreach (var item in m_AddMiniProgramItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }
            foreach (var item in m_SubscribeItemList) {
                if (item is IDisposable disposable) {
                    disposable.Dispose();
                }
            }

            base.Dispose();
        }

        public bool Share => m_Share.Value;
        [Autowired]
        private readonly IBlockerData m_Share;
        private List<IBoolData> m_ShareItemList = new();
        void IDFR_FeatureModelInternal.AddShare(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_Share.Add(item);
            m_ShareItemList.Add(item);
        }

        public bool SideBar => m_SideBar.Value;
        [Autowired]
        private readonly IBlockerData m_SideBar;
        private List<IBoolData> m_SideBarItemList = new();
        void IDFR_FeatureModelInternal.AddSideBar(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_SideBar.Add(item);
            m_SideBarItemList.Add(item);
        }

        public bool Desktop => m_Desktop.Value;
        [Autowired]
        private readonly IBlockerData m_Desktop;
        private List<IBoolData> m_DesktopItemList = new();
        void IDFR_FeatureModelInternal.AddDesktop(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_Desktop.Add(item);
            m_DesktopItemList.Add(item);
        }

        public bool GameClub => m_GameClub.Value;
        [Autowired]
        private readonly IBlockerData m_GameClub;
        private List<IBoolData> m_GameClubItemList = new();
        void IDFR_FeatureModelInternal.AddGameClub(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_GameClub.Add(item);
            m_GameClubItemList.Add(item);
        }

        public bool AddMiniProgram => m_AddMiniProgram.Value;
        [Autowired]
        private readonly IBlockerData m_AddMiniProgram;
        private List<IBoolData> m_AddMiniProgramItemList = new();
        void IDFR_FeatureModelInternal.AddMiniProgram(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_AddMiniProgram.Add(item);
            m_AddMiniProgramItemList.Add(item);
        }

        public bool Subscribe => m_Subscribe.Value;
        [Autowired]
        private readonly IBlockerData m_Subscribe;
        private List<IBoolData> m_SubscribeItemList = new();
        void IDFR_FeatureModelInternal.AddSubscribe(bool value) {
            var item = KHBD.TypeMap.Instantiate<IBoolData>();
            item.SetValueWithOutEvent(value);
            m_Subscribe.Add(item);
            m_SubscribeItemList.Add(item);
        }
    }
}

namespace Internal.Runtime.Models {

    public interface IDFR_FeatureModelInternal {

        void AddShare(bool value);

        void AddSideBar(bool value);

        void AddDesktop(bool value);

        void AddGameClub(bool value);

        void AddMiniProgram(bool value);
        
        void AddSubscribe(bool value);
    }
}
